<template>
  <div>
         <Like v-for="(item,index) in list" :key="index"
       :img="item.dogImgUrl"
       :name="item.dogName"
       :index='index'
       @likedog="fn"
      />
       <span>您喜欢的图片如下:<br>{{str}} </span>
        
  </div>
</template>

<script>
import Like from './components/选择喜欢的狗.vue'

export default {
       components:{
         Like
       },
          data(){
        return{
            str :'',
                 list: [
    {
        dogImgUrl: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Flmg.jj20.com%2Fup%2Fallimg%2F1114%2F041621122252%2F210416122252-1-1200.jpg&refer=http%3A%2F%2Flmg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1669468644&t=e2d0a62a58190fabf0abfc59453838f2",
        dogName: "向日葵",
    },
    {
        dogImgUrl:"https://img1.baidu.com/it/u=3622442929,3246643478&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
        dogName: "红花",
    },
    {
        dogImgUrl:"https://img0.baidu.com/it/u=3156137851,1307209439&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
        dogName: "雏菊",
    },
    {
        dogImgUrl:"https://img2.baidu.com/it/u=1893470775,4143435497&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
        dogName: "森林",
    },
    {
        dogImgUrl:"https://img0.baidu.com/it/u=922902802,2128943538&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800",
        dogName: "黄花",
    },
    {
        dogImgUrl:"https://img2.baidu.com/it/u=231475710,2178882669&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        dogName: "雪花",
    },
],
      
        }
        
      },
      methods:{
        fn(index){
              //  console.log(this.str = this.list[index].dogName);
                  this.str = this.str + this.list[index].dogName
                 
                  
               
        }
      }
}
</script>

<style>

</style>